#include "menu.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int 
main(void)
{
	char           *choice;
	int             ch;
	menu            new;
	printf("Welcome to menu editor!!!\n");
	printf("1: create the menu\n");
	printf("2: insert node in the level\n");
	printf("3: insert node in the sublevel\n");
	printf("4: delete node\n");
	printf("5: change nodes\n");
	printf("6: move the cursor right\n");
	printf("7: move the cursor left\n");
	printf("8: move the cursor up\n");
	printf("9: move the cursor down\n");
	printf("10: print current node\n");
	printf("11: print the sublevel\n");
	printf("12: print the current level\n");
	printf("13: print the menu\n");
	printf("14: change the content of the node\n");
	printf("15: destroy the menu\n");
	while (scanf("%s", choice) != EOF) {
		if (strcmp("1", choice) == 0) {
			new = create();
			continue;
		}
		if (strcmp("2", choice) == 0) {
			printf("Type the element you want to insert in the level\n");
			scanf("%s", choice);
			insert_node(new, choice);
			continue;
		}
		if (strcmp("3", choice) == 0) {
			printf("Type the element you want to insert in the sub level\n");
			scanf("%s", choice);
			insert_subnode(new, choice);
			continue;
		}
		if (strcmp("4", choice) == 0) {
			delete_node(new);
			continue;
		}
		if (strcmp("5", choice) == 0) {
			change_nodes(new);
			continue;
		}
		if (strcmp("6", choice) == 0) {
			next(new);
			continue;
		}
		if (strcmp("7", choice) == 0) {
			previous(new);
			continue;
		}
		if (strcmp("8", choice) == 0) {
			up(new);
			continue;
		}
		if (strcmp("9", choice) == 0) {
			down(new);
			continue;
		}
		if (strcmp("10", choice) == 0) {
			print(new);
			continue;
		}
		if (strcmp("11", choice) == 0) {
			print_sublevel(new);
			continue;
		}
		if (strcmp("12", choice) == 0) {
			print_level(new);
			continue;
		}
		if (strcmp("13", choice) == 0) {
			print_menu(new);
			continue;
		}
		if (strcmp("14", choice) == 0) {
			printf("Type the string you want to insert\n");
			scanf("%s", choice);
			change(new, choice);
			continue;
		}
		if (strcmp("15", choice) == 0) {
			destroy(new);
			continue;
		}
	}

}
